package com.chlitina.store.modules.inventory.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.modules.base.entity.StoreProduct;

/**
 * 入库Entity
 * @author Songsong.XU
 * @version 2013-11-08
 */
@Entity
@Table(name = "store_inventory_in_detail")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class StoreInventoryInDetail extends BaseEntity {
	public final static int RED_STATUS = 1;// 已冲红
	public final static int NORMAL_STATUS = 0; //正常入库
	public final static int IN_SYSTEM=0;//系统产品
	public final static int IN_SELF=1;//店面自营产品
	
	private static final long serialVersionUID = 1L;
	private Long id; // 入库单明细编号
	private StoreInventoryIn storeInventoryIn;
	private StoreProduct storeProduct;
	private int amount;
	public StoreInventoryInDetail() {
	}

	public StoreInventoryInDetail(Long id){
		this();
		this.id = id;
	}
	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="SII_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public StoreInventoryIn getStoreInventoryIn() {
		return storeInventoryIn;
	}

	public void setStoreInventoryIn(StoreInventoryIn storeInventoryIn) {
		this.storeInventoryIn = storeInventoryIn;
	}

	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="PRODUCT_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public StoreProduct getStoreProduct() {
		return storeProduct;
	}

	public void setStoreProduct(StoreProduct storeProduct) {
		this.storeProduct = storeProduct;
	}
	
	@Column(name="AMOUNT")
	public int getAmount() {
		return amount;
	}

	public void setAmount(int amount) {
		this.amount = amount;
	}
}

 
 
 
 
 
 


